<?php
include_once "../common.php";
$_SESSION['login'] = array();
unset($_SESSION['login']);

// check login
if(
	isset($_POST['email']) && !empty($_POST['email'])
	&& isset($_POST['password']) && !empty($_POST['password'])
	)
{
	// check data
	$query = "	SELECT 
					* 
				FROM Customers 
				WHERE Email = '".str_replace("'","&#39;",$_POST['email'])."'
					AND Password = MD5('".str_replace("'","&#39;",$_POST['password'])."') 
				LIMIT 1";
	$result = $_MySQL->runQuery($query);
	if(mysql_num_rows($result) == 1)
	{
		$row = mysql_fetch_assoc($result);
		$_SESSION['login'] = $row;
		if($_POST['remember'])
		{
			// coockie
		}
		echo "succes";
	}
	else 
	{
		echo "Incorrecte email en/of wachtwoord";	
	}
}
else 
{
	echo "Niet alle waarden zijn ingevuld";	
}
